/***********************************************
 This file is part of redia-bapps-main-ios.
 
 Copyright (c) 2015 Redia A/S
 
 Redia-bapps-main-ios is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 Redia-bapps-main-ios is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with redia-bapps-main-ios.  If not, see <http://www.gnu.org/licenses/>.
 
 *********************************************** */

//
//  BAAboutCreator.m
//  redia-bapps-ios
//
//  Created by Mads Darø Kristensen on 10/8/13.
//  Copyright (c) 2013 redia. All rights reserved.
//

#import "BAAboutCreator.h"
#import "JSONEncodingHelperMethods.h"

@implementation BAAboutCreator

+ (id)objectWithJSONObject:(NSDictionary *)jsonObj
{
    BAAboutCreator *obj = [[BAAboutCreator alloc] init];
    
    obj.abstract = [JSONEncodingHelperMethods parseStringWithKey:@"abstract" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.abstract);
    obj.nameInverted = [JSONEncodingHelperMethods parseStringWithKey:@"nameInverted" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.nameInverted);
    obj.type = [JSONEncodingHelperMethods parseStringWithKey:@"type" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.type);
    obj.name = [JSONEncodingHelperMethods parseStringWithKey:@"name" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.name);
    obj.url = [JSONEncodingHelperMethods parseStringWithKey:@"url" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.url);
    
    return obj;
}

- (NSDictionary *)toJSONObject
{
    EXPECT_OBJECT(NSString, self.abstract);
    EXPECT_OBJECT(NSString, self.nameInverted);
    EXPECT_OBJECT(NSString, self.type);
    EXPECT_OBJECT(NSString, self.name);
    EXPECT_OBJECT(NSString, self.url);

    return @{
             @"abstract": self.abstract,
             @"nameInverted": self.nameInverted,
             @"type": self.type,
             @"name": self.name,
             @"url": self.url
             };
}

@end
